#ifndef H_DEFINES_H
#define H_DEFINES_H

#define DRIVER_VER						"1.0"

#define DRIVER_MAJOR					245
#define DRIVER_NAME						"kgdu"
#define DRIVER_NODE						"/dev/"DRIVER_NAME

/* kind of magic number for one ioctl group */
#define IOCTL_GDU_MAGIC					'l'
/* we have 14 ioctls here, change value if you change */
#define IOCTL_GDU_MAX_NR				24

#define	IOCTL_GPIO_DIR_IN				_IOW(IOCTL_GDU_MAGIC, 0, int)
#define IOCTL_GPIO_DIR_OUT				_IOW(IOCTL_GDU_MAGIC, 1, int)
#define	IOCTL_GPIO_LEVEL				_IOWR(IOCTL_GDU_MAGIC, 2, int)
#define IOCTL_GPIO_OUT_SET				_IOW(IOCTL_GDU_MAGIC, 3, int)
#define	IOCTL_GPIO_OUT_CLR				_IOW(IOCTL_GDU_MAGIC, 4, int)
#define IOCTL_FPGA_READ					_IOWR(IOCTL_GDU_MAGIC, 5, int)
#define IOCTL_FPGA_WRITE				_IOW(IOCTL_GDU_MAGIC, 6, int)
#define IOCTL_MSGFLAG_WRITE				_IOW(IOCTL_GDU_MAGIC, 7, int)
#define IOCTL_MSGFLAG_READ				_IOWR(IOCTL_GDU_MAGIC, 8, int)
#define IOCTL_MSGFLAG_SET				_IOW(IOCTL_GDU_MAGIC, 9, int)
#define IOCTL_MSGFLAG_CLR				_IOW(IOCTL_GDU_MAGIC, 10, int)
#define IOCTL_MSGFLAG_QUERY				_IOWR(IOCTL_GDU_MAGIC, 11, int)
#define IOCTL_GPIO_PID_IN				_IOW(IOCTL_GDU_MAGIC, 12, int)
#define IOCTL_ADC_GET_VAL				_IOR(IOCTL_GDU_MAGIC, 13, int)
#define IOCTL_OCXO_TEMP					_IOR(IOCTL_GDU_MAGIC, 14, int)
#define IOCTL_BOARD_TEMP				_IOR(IOCTL_GDU_MAGIC, 15, int)
#define IOCTL_TEMP_CONFIG				_IOR(IOCTL_GDU_MAGIC, 16, int)
#define IOCTL_1PPS_GET_TIME				_IOWR(IOCTL_GDU_MAGIC, 17, int)
#define IOCTL_1PPS_SET_TIME				_IOWR(IOCTL_GDU_MAGIC, 18, int)
#define IOCTL_PCK1_ENABLE				_IOWR(IOCTL_GDU_MAGIC, 19, int)
#define IOCTL_PCK1_ENABLE				_IOWR(IOCTL_GDU_MAGIC, 19, int)
#define IOCTL_SHOW_EMAC_REGS			_IOWR(IOCTL_GDU_MAGIC, 20, int)
#define IOCTL_TEMP_RESET				_IOWR(IOCTL_GDU_MAGIC, 21, int)
#define IOCTL_TOD_SET					_IOW(IOCTL_GDU_MAGIC, 22, F_TOD_)
#define IOCTL_TOD_GET					_IOR(IOCTL_GDU_MAGIC, 23, F_TOD_)


#define	max(a,b)	( (a>b)? (a): (b))
#define	min(a,b)	( (a<b)? (a): (b))
#define MAbs(x)		( (x>0) ? (x): -(x)) 
	
#ifndef false
#define false 0
#endif

#ifndef true
#define true  1
#endif

typedef unsigned char BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned int LONG;
typedef	unsigned long	Ulong;

#define wbD0	0x0001  /* 0x0001 */
#define wbD1	0x0002  /* 0x0002 */
#define wbD2	0x0004  /* 0x0004 */
#define wbD3	0x0008  /* 0x0008 */
#define wbD4	0x0010  /* 0x0010 */
#define wbD5	0x0020  /* 0x0020 */
#define wbD6	0x0040  /* 0x0040 */
#define wbD7	0x0080  /* 0x0080 */

#define wbD8	0x0100  /* 0x0100 */
#define wbD9	0x0200  /* 0x0200 */
#define wbD10	0x0400  /* 0x0400 */
#define wbD11	0x0800  /* 0x0800 */
#define wbD12	0x1000  /* 0x1000 */
#define wbD13	0x2000  /* 0x2000 */
#define wbD14	0x4000  /* 0x4000 */
#define wbD15	0x8000  /* 0x8000 */

#ifndef PB0
#define PB0		wbD0
#define PB1		wbD1
#define PB2		wbD2
#define PB3		wbD3
#define PB4		wbD4
#define PB5		wbD5
#define PB6		wbD6
#define PB7		wbD7
#define PB8		wbD8
#define PB9		wbD9
#define PB10	wbD10
#define PB11	wbD11
#define PB12	wbD12
#define PB13	wbD13
#define PB14	wbD14
#define PB15	wbD15
#endif

#ifndef PA0
#define PA0		wbD0
#define PA1		wbD1
#define PA2 	wbD2
#define PA3 	wbD3
#define PA4 	wbD4
#define PA5 	wbD5
#define PA6 	wbD6
#define PA7 	wbD7
#define PA8 	wbD8
#define PA9 	wbD9
#define PA10 	wbD10
#define PA11 	wbD11
#define PA12 	wbD12
#define PA13 	wbD13
#define PA14 	wbD14
#define PA15 	wbD15
#endif


#define lbD0	0x0001  /* 0x0001 */
#define lbD1	0x0002  /* 0x0002 */
#define lbD2	0x0004  /* 0x0004 */
#define lbD3	0x0008  /* 0x0008 */
#define lbD4	0x0010  /* 0x0010 */
#define lbD5	0x0020  /* 0x0020 */
#define lbD6	0x0040  /* 0x0040 */
#define lbD7	0x0080  /* 0x0080 */

#define lbD8	0x0100  /* 0x0100 */
#define lbD9	0x0200  /* 0x0200 */
#define lbD10	0x0400  /* 0x0400 */
#define lbD11	0x0800  /* 0x0800 */
#define lbD12	0x1000  /* 0x1000 */
#define lbD13	0x2000  /* 0x2000 */
#define lbD14	0x4000  /* 0x4000 */
#define lbD15	0x8000  /* 0x8000 */

#define lbD16	0x00010000
#define lbD17	0x00020000
#define lbD18	0x00040000
#define lbD19	0x00080000

#define lbD20	0x00100000
#define lbD21	0x00200000
#define lbD22	0x00400000
#define lbD23	0x00800000

#define lbD24	0x01000000
#define lbD25	0x02000000
#define lbD26	0x04000000
#define lbD27	0x08000000

#define lbD28	0x10000000
#define lbD29	0x20000000
#define lbD30	0x40000000
#define lbD31	0x80000000

#define bbD0	0x01
#define bbD1	0x02
#define bbD2	0x04
#define bbD3	0x08

#define bbD4	0x10
#define bbD5	0x20
#define bbD6	0x40
#define bbD7	0x80 




//--------------------------
#define WARM_START_BOOTING	0
#define WARM_START_UPDATE	1
#define WARM_START_APPLY	2


#define WarmStart(x)

#endif



